home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / GSDMO_19.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-02  |  2KB  |  70 lines

  1. program GSDMO_19;
  2. {------------------------------------------------------------------------------
  3.                              DBase File Sorting
  4.  
  5.        Copyright (c)  Richard F. Griffin
  6.  
  7.        06 February 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This program demonstrates how dBase files may be sorted using
  14.        Griffin Solutions units.
  15.  
  16.        The program creates (if necessary) and opens a dBase file and its
  17.        memo. It then sorts the file to GSDMO19S.DBF and GSDMO19S.DBT.
  18.        The sort fields are LASTNAME and FIRSTNAME.
  19.  
  20.        Records will only be sorted if they are valid (i.e., deleted records
  21.        are ignored if SetDeletedOn, and SetFilterThru must validate the
  22.        record as well).
  23.  
  24.        New procedures/functions introduced are:
  25.  
  26.                  SortTo
  27.  
  28. -------------------------------------------------------------------------------}
  29.  
  30. uses
  31.    GSOB_Var,
  32.    GSOB_Gen,
  33.    GSOBShel,
  34.    {$IFDEF WINDOWS}
  35.       WinCRT;
  36.    {$ELSE}
  37.       CRT;
  38.    {$ENDIF}
  39.  
  40. var
  41.    fx : file;
  42.  
  43. begin
  44.    ClrScr;
  45.  
  46.    if not FileExist('GSDMO_19.DBF') then
  47.    begin
  48.       writeln('Creating GSDMO_19.DBF');
  49.       MakeTestData(3,'GSDMO_19', 20, true);   {Make a dBase III file w/memo}
  50.       writeln('GSDMO_19.DBF Created');
  51.    end;
  52.  
  53.    Select(1);
  54.    Use('GSDMO_19');
  55.    Writeln('Sorting to file GSDMO19S.DBF..');
  56.    SortTo('GSDMO19S','LASTNAME+FIRSTNAME',SortUp);
  57.    Writeln('Listing from Sorted file GSDMO19S.DBF..');
  58.    Select(2);                     {Use record area 2 for new file}
  59.    Use('GSDMO19S');               {Assign the sorted dBase III file GSDMO19S}
  60.    GoTop;
  61.    while not dEOF do
  62.    begin
  63.       writeln(FieldGet('LASTNAME'),' ',
  64.               FieldGet('FIRSTNAME'),'  ',
  65.               RecNo);
  66.       Skip(1);
  67.    end;
  68.    CloseDataBases;
  69. end.
  70.